package club.haomoon.core.mapper.admin;

import club.haomoon.core.common.BaseDataMpper;
import club.haomoon.core.entity.admin.AdminData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * -------------------------
 * @Description: 系统管理员Mapper
 * @Author: Wangjianwei
 * @Date: 2025/02/11 16:30
 * -------------------------
 */
@Mapper
public interface AdminDataMapper extends BaseDataMpper<AdminData> {
    @Select("SELECT * FROM cms_admin_data admin INNER JOIN cms_admin_dept_data lad ON admin.id = lad.admin_id WHERE lad.dept_id = #{deptId} AND admin.delete_time IS NULL")
    List<AdminData> getListByDept(@Param("deptId") Integer deptId);

    @Select("SELECT * FROM cms_admin_data admin INNER JOIN cms_admin_jobs_data lad ON admin.id = lad.admin_id WHERE lad.jobs_id = #{jobId} AND admin.delete_time IS NULL")
    List<AdminData> getListByJobs(@Param("jobId") Integer jobId);


    @Select("SELECT count(*) FROM cms_admin_data admin INNER JOIN cms_admin_role_data lad ON admin.id = lad.admin_id WHERE lad.role_id = #{roleId} AND admin.delete_time IS NULL")
    Integer getCountByRoleId(@Param("roleId") Integer roleId);

}
